﻿using System;
using ZX.Web.UI.Controls;
using System.Text;
using ZX.CRM.Bussiness;
using System.Data;

namespace ZX.WebApp.DeskTop.DeskTopItem
{
    public partial class CrmOrderProductReport :BasePage
    {
        BCrmReport BReport = new BCrmReport();
        protected void Page_Load(object sender, EventArgs e)
        {
            getdt();
        }

        private int getPowerType
        {
            get
            {
                int powertype = 0;
                if (Request["PowerType"] == null || Request["PowerType"] == "" || Request["PowerType"] == "0")
                    powertype = 0;
                else
                    powertype = 1;
                return powertype;
            }
        }

        private int getProductType
        {
            get
            {
                int productType = 0;
                if (Request["ProductType"] == null || Request["ProductType"] == "")
                    productType = 0;
                productType = int.Parse(Request["ProductType"]);
                return productType;
            }
        }

        public void getdt()
        {
            var htmlTemp = "";
            htmlTemp = "";
            htmlTemp += "<div style='width:100%;height:90%;overflow:auto;'><table class='tableContent' cellspacing='0'>";
            htmlTemp += "<tr>";
            htmlTemp += "    <th style='width:35%;border-left:1px solid #C1DAD7;'>产品名称</th>";
            htmlTemp += "    <th style='width:25%;'>未交付</th>";
            htmlTemp += "    <th style='width:20%;'>交付中</th>";
            htmlTemp += "    <th style='width:20%;'>已交付</th></tr>";

            DataTable MyDataTable = new DataTable();
            StringBuilder sb = new StringBuilder();
            MyDataTable = BReport.ReturnCrmOrderProductReport(new Guid(this.UserId.ToString()), getProductType, getPowerType);
            if (MyDataTable.Rows.Count > 0)
            {
                foreach (DataRow row in MyDataTable.Rows)
                {
                    htmlTemp += "<tr><td style='border-left:1px solid #C1DAD7;'>" + row["Caption"].ToString() + "</td>";
                    htmlTemp += "<td>" + row["未交付"].ToString() + "</td>";
                    htmlTemp += "<td>" + row["交付中"].ToString() + "</td>";
                    htmlTemp += "<td>" + row["已交付"].ToString() + "</td></tr>";
                }
            }
            else
            {
                htmlTemp += "<tr><td colspan='4' style='border-left:1px solid #C1DAD7;'>没有数据...</td>";
            }
            htmlTemp += " </table></div>";

            Response.Clear();
            Response.Write(htmlTemp);
            Response.End();
        }
    }
}